package com.lpe.service.impl;

import com.alibaba.fastjson.JSON;
import com.lpe.dao.UserInfoDao;
import com.lpe.pojo.User;
import com.lpe.pojo.vo.ResultVo;
import com.lpe.service.UserInfoService;
import com.lpe.sys.SysCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by b5m on 2017/11/28.
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private UserInfoDao userInfoDao;

    @Override
    public User findUserById(Integer id) {
        User user = userInfoDao.findUserById(id);
        logger.info("执行查询id为【{}】用户操作成功,结果为【{}】", id, JSON.toJSONString(user));
        return user;
    }

    @Override
    @Transactional
    public User insertUser(User user) {
        user = new User();
        user.setName("林chen");
        user.setPassword("2132");
        userInfoDao.insertUser(user);
        return user;
    }
}
